<?php include dirname(__FILE__).'/common/header.php'; ?>

<?php include dirname(__FILE__).'/common/menu.php'; ?>

var attr = {};
attr.ctrlName = '<?php echo $ctrlName; ?>';
attr.province = <?php echo $province; ?>;

var questions = [{
    "title": "服务启动",
    "content": [
        "保养/维修安排的便利性（通过电话，短信等，也包括和服务人员沟通的时间）",
        "灵活地安排您希望保养/维修的时间",
        "接车过程及时高效(您等待被招呼的时间，和服务顾问沟通的时间，钥匙交接和填写书面文件的时间)"
    ]
},{
    "title": "服务顾问",
    "content": [
        "服务顾问礼貌",
        "服务顾问有求必应",
        "详细地解释保养/维修的内容和收费情况"
    ]
},{
    "title": "经销商设施",
    "content": [
        "开车进/出经销商/服务站容易",
        "经销商/服务站所处位置便利",
        "经销商/服务站干净整洁",
        "顾客休息区舒适(包括座椅、娱乐设施、饮料点心)"
    ]
},{
    "title": "服务后交车",
    "content": [
        "提车过程及时高效(等待被接待的时间，填写书面文件和提车)",
        "收费合理",
        "周到地协助我提车(如协助找到车辆、付款等)"
    ]
},{
    "title": "服务质量",
    "content": [
        "完成整个保养/维修所花的时间",
        "保养/维修完成很彻底",
        "保养/维修后的车干净并且车况良好(无损坏，车内设置无变化)"
    ]
}];

var headers = [['user_code','店铺编码'],['user_name','店铺名称'],['user_province','店铺省份'],['user_city','店铺城市'],['openid','openid']
    ,['score','打分总和']
    ,['customer_phone','手机号'],['customer_car_number','车牌号'],['customer_time_create','绑定时间'],['customer_time_survey_start','问卷开始时间']
    ,['customer_time_survey','问卷提交时间'],['customer_survey_cost','消耗时间(秒)']
];
Ext.each(questions,function(q,i) {
    for(var j=0;j < q.content.length; j++) {
        headers.push(['question_'+(i+1)+'_'+(j+1),q.title+'-'+q.content[j],function(val) {return val||'';}]);
    }
});


/*
| -------------------------------------------------------------------
|  List Grid
| -------------------------------------------------------------------
*/
var grid = new ZM.GridPanel({
    url: list.baseUrl + attr.ctrlName+'/getCustomerList',
    onlyShow:true,
    tbar:[{
        text:'导出过滤数据',
        cls:'btn-show',
        hidden:!Ext.permission[attr.ctrlName + '/getCustomerList'.toLowerCase()],
        handler:function() {
            exportExcel(grid,headers,'广汽搜索问卷','广本冬季调查问卷-20161201-00.xlsx'+(new Date().format('yyyyMMdd'))+'-'+parseInt(Math.random()*100)+'.xlsx');
        }
    },'-',{
        text:'导出平均打分数据',
        cls:'btn-show',
        hidden:!Ext.permission[attr.ctrlName + '/exportShopScore'.toLowerCase()],
        handler:function() {
            location.href = attr.ctrlName + '/exportShopScore?'+(new Date().getTime());
        }
    }],
    columns:[
        //{header:'ID',dataIndex:'customer_id',width:60,filter:{}},
        {header:'店铺编码',dataIndex:'user_code',filter:{}},
        {header:'店铺名称',dataIndex:'user_name',filter:{}},
        {header:'店铺省份',dataIndex:'user_province',filter:{xtype:'combofield',options:[['','全部']].concat(attr.province)}},
        {header:'店铺城市',dataIndex:'user_city',filter:{}},
        {header:'openid',dataIndex:'openid',width:140,filter:{}},
        {header:'打分总和',dataIndex:'score',sort:true},
        {header:'手机号',dataIndex:'customer_phone'},
        {header:'车牌号',dataIndex:'customer_car_number'},
        {header:'绑定时间',dataIndex:'customer_time_create',width:140,filter:{xtype:'daterangefield'}},
        {header:'问卷开始时间',dataIndex:'customer_time_survey_start',width:140},
        {header:'问卷提交时间',dataIndex:'customer_time_survey',width:140,filter:{xtype:'daterangefield'}},
        {header:'消耗时间(秒)',dataIndex:'customer_survey_cost',width:100},
        {header:'操作',renderer:function(v,p,r){
            var str = '';
            if(r.json.content_id>0) str += Ext.rd('查看提交结果','fireDetail',r,attr.ctrlName+'/getCustomerList');
            return str;
        }}
    ]
});

var panel = new Ext.Panel({
	xtype:'panel',
	region:'east',
	split:true,
	collapseMode:'mini',
	collapsible:true,
	autoScroll:true,
	width:320
});

list.grid = new Ext.Container({
    layout:'border',
    items:[grid,panel]
});

function refreshData(r) {
	r = r.json;
    if(r.content_id == 0) {
        panel.body.update('<div>没有参与调查</div>');
        return;
    }
	var _html = '<style>.page-survey dl {    margin: 40px 2% 0;    line-height: 1.6;    font-size: 12px;    padding-bottom: 20px;     }.page-survey dt {    font-size: 16px;    text-align: center;    margin: -15px auto 0;    position: relative;    width: 90px;    }.page-survey dd {    padding: 20px 10px 0 25px;}.page-survey dd span {    display: flex;    align-items: center;    justify-content: center;    margin-top: 5px;}.page-survey dd span i {    display: inline-block;    min-width: 20px; height: 20px;    flex: 1;    margin: 1px;    position: relative;}.page-survey dd span i::before {    content: "";    position: absolute;    left: 0;    top: 50%;    width: 100%;    height: 2px;    margin-top: -1px;}.page-survey dd span .green::before {    background: #02bb70;}.page-survey dd span .yellow::before {    background: #ffc300;}.page-survey dd span .red::before {    background: #db004d;}.page-survey dd span .gray::before {    background: #042d4b;}.page-survey dd span em {    display: inline-block;    width: 30px;    height: 18px;    text-align: center;    border: 1px #069bf6 solid;    font-size: 12px;    color: #069bf6;    line-height: 18px;    margin-left: 8px;}.page-survey dd p {    position: relative;}.page-survey dd p::before {    content: "";    position: absolute;    left: -17px;    top: 2px;    width: 14px;    height: 14px;}.page-survey dd:nth-of-type(1) p::before {    background: url("http://ghac.twomi.cn/2016wap/hdsurvey/images/sprit.png") 0 -75px/320px 320px no-repeat;}.page-survey dd:nth-of-type(2) p::before {    background: url("http://ghac.twomi.cn/2016wap/hdsurvey/images/sprit.png") -15px -75px/320px 320px no-repeat;}.page-survey dd:nth-of-type(3) p::before {    background: url("http://ghac.twomi.cn/2016wap/hdsurvey/images/sprit.png") -32px -75px/320px 320px no-repeat;}.page-survey dd:nth-of-type(4) p::before {    background: url("http://ghac.twomi.cn/2016wap/hdsurvey/images/sprit.png") -47px -75px/320px 320px no-repeat;}    </style>\
		<div class="page-survey">';
	Ext.each(r.params,function(p,i){
		html += '<p><label>'+p.name+(p.label?('('+p.label+')'):'')+(p.optional?'':'<span style="color:red">*</span>')+':</label><input type="'+(p.type||'text')+'" name="'+p.name+'" value="'+(p.value||'')+'" size="20"></p>';
		if(p.type == 'file') {
			hasFile = true;
		}
	});
    var html = [];
    for(var i=0,len = questions.length; i < len; i++) {
        html.push('<dl>');
        html.push('<dt>'+questions[i].title+'</dt>');
        for(var j=0,jlen = questions[i].content.length;j < jlen;j++) {
            var index = r['question_'+(i+1)+'_'+(j+1)];
            html.push('<dd><p>' + questions[i].content[j] +'</p><span>');
            var _h = [];
            for(var n=0;n < 10;n++) {
                var className = n <= Math.min(2,index - 1) ? 'green' :
                    (n <= Math.min(6,index - 1) ? 'yellow' : (n <= Math.min(9,index - 1) ? 'red': 'gray'));
                _h.push('<i data-index="'+n+'" class="'+className+'"></i>');
            }
            html.push(_h.join(''));
            html.push('<em>'+index+'分</em></span></dd>');
        }
        html.push('</dl>');
    }
    _html += html.join('');
	_html += '</div>'
	panel.body.update(_html);
}

grid.on('rowclick',function(grid,rowIndex,e) {
	var r = grid.getStore().getAt(rowIndex);
	refreshData(r);
});



<?php include dirname(__FILE__).'/common/layout.php'; ?>
grid.store.load();
grid.store.on('load',function(s){
	var r = s.getAt(0);
	if(r) {
		refreshData(r);
		grid.getSelectionModel().selectFirstRow();
	}
});
<?php include dirname(__FILE__).'/common/footer.php'; ?>
